home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Compilers⁄Interps / GCC-2.3.3r12 / Sources-Apple / fopen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-08  |  696 b   |  31 lines  |  [TEXT/MPS ]

  1. /* A new and improved fopen that makes MPW text files. */
  2.  
  3. /* This should only be compiled and linked under MPW - note that config.h
  4.    must *not* be included, or "mpw_fopen" will call itself! */
  5.  
  6. #include <StdIO.h>
  7. #include <Files.h>
  8.  
  9. FILE *
  10. mpw_fopen(name, mode)
  11. char *name, *mode;
  12. {
  13.     char *pname = (char *) malloc(strlen(name) + 2);
  14.     OSErr e;
  15.     FILE *fp;
  16.     struct FInfo fi;
  17.  
  18.     pname[0] = strlen(name);
  19.     strcpy(pname+1, name);
  20.     
  21.     fp = fopen(name, mode);
  22.     
  23.     e = GetFInfo(pname, 0, &fi);
  24.     /* should do spiffier error handling */
  25.     if (e != 0) printf("%d\n", e);
  26.     fi.fdType = (OSType) 'TEXT';
  27.     fi.fdCreator = (OSType) 'MPS ';
  28.     e = SetFInfo(pname, 0, &fi);
  29.     if (e != 0) printf("%d\n", e);
  30.     return fp;
  31. }